﻿using Ewell.Interface.Common.Model.GateWay.Dto.Dict;
using Ewell.Interface.Common.Model.GateWay;
using Ewell.Interface.Common.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ewell.Interface.Common.Model.GateWay.GateWayUriInfo;

namespace Ewell.Interface.Common.Model.Config
{
    public class ProxyConfig
    {
        public static string his_getway_url = JsonConfig.ReadConfig("package", "his_getway_url");

        public Dictionary<string, string> GetInterfaceConfig(long interfaceId)
        {
            Dictionary<string, string> result=new Dictionary<string, string>();
            InterfaceConfigQueryReq interfaceConfigQueryReq = new InterfaceConfigQueryReq()
            {
                interfaceId = interfaceId
            };
            InterfaceManagementDubboServe interfaceManagement = new InterfaceManagementDubboServe();
            GateWayResult<List<InterfaceXConfigResp>> gateWayResult = interfaceManagement.queryInterfaceConfigByExample.Post<List<InterfaceXConfigResp>>(interfaceConfigQueryReq);
            foreach (var item in gateWayResult.@object)
            {
                if (!result.ContainsKey(item.configKey))
                    result.Add(item.configKey, item.configValue ?? item.configDefaultValue);
            }
            return result;
        }
    }
}
